//
//  UThemes.h
//  UltraStarDeluxeIOS
//
//  Created by 李 杰军 on 12-7-15.
//  Copyright (c) 2012年 DoReiMi. All rights reserved.
//

#ifndef UltraStarDeluxeIOS_UThemes_h
#define UltraStarDeluxeIOS_UThemes_h

#include <string.h>
#include <vector.h>

#include "UTexture.h"

struct TRGB
{
    float R;
    float G;
    float B;
};

struct TRGBA
{
    float R;
    float G;
    float B;
    float A;
};

enum TBackgroundType
{
    bgtNone = 0,
    bgtColor,
    bgtTexture,
    bgtVideo,
    bgtFade,
    bgtAuto,
    
    bgtNum,
};

extern const std::string BGT_Names[bgtNum];

struct TThemeBackground
{   
    TBackgroundType BGType;
    TRGB Color;
    std::string Tex;
    float Alpha;
};

extern const TThemeBackground DEFAULT_BACKGROUND;

struct TThemeStatic
{
    int X;
    int Y;
    float Z;
    int W;
    int H;
    std::string Color;
    float ColR;
    float ColG;
    float ColB;
    std::string Tex;
    TTextureType Typ;
    float TexX1;
    float TexY1;
    float TexX2;
    float TexY2;
    
    bool Reflection;
    float Reflectionspacing;
};

typedef std::vector<TThemeStatic> AThemeStatic;

struct TThemeText
{
    int X;
    int Y;
    int W;
    float Z;
    std::string Color;
    float ColR;
    float ColG;
    float ColB;
    int Font;
    int Size;
    int Align;
    std::string Text;
    
    bool Reflection;
    float ReflectionSpacing;
};

typedef std::vector<TThemeText> AThemeText;

struct TThemeButton
{
    AThemeText Text;
    int X;
    int Y;
    float Z;
    int W;
    int H;
    std::string Color;
    float ColR;
    float ColG;
    float ColB;
    float Int;
    std::string DColor;
    float DColR;
    float DColG;
    float DColB;
    float DInt;
    std::string Tex;
    TTextureType Typ;
    
    bool Visible;
    
    // Reflection Mod
    bool Reflection;
    float Reflectionspacing;
    
    // Fade Mod
    int SelectH;
    int SelectW;
    bool Fade;
    bool FadeText;
    float DeSelectReflectionspacing;
    std::string FadeTex;
    int FadeTexPos;
    
    // Button Collection Mod
    int Parent; // Number of the Button Collection this Button is assigned to. IF 0: No Assignement
};

// Button Collection Mod
struct TThemeButtonCollection 
{
    TThemeButton Style;
    int ChildCount; // No of assigned Childs
    int FirstChild; // No of Child on whose Interaction Position the Button Should be
};

typedef std::vector<TThemeButtonCollection> AThemeButtonCollection;
typedef AThemeButtonCollection* PAThemeButtonCollection;

class TThemeBasic
{
public:
    TThemeBackground Background;
    AThemeText Text;
    AThemeStatic Statics;
    
    // Button Collection Mod
    AThemeButtonCollection ButtonCollection;
};

typedef TThemeBasic* PThemeBasic;

class TThemeLoading : public TThemeBasic
{
    TThemeStatic StaticAnimation;
    TThemeText TextLoading;
};

class TTheme 
{
private:
    void CreateThemeObjects();
    
    void LoadHeader(const std::string& FileName);
    
public:
    TThemeLoading* Loading;
    
    TTheme();
    virtual ~TTheme();
    
    void LoadList();
    
    bool LoadTheme(int ThemeNum, int sColor);
};

extern TTheme* Theme;

#endif
